var index = 0;
var flag = true;
var timer = null;

//获取第一张图片的宽度
var imgWidth = $(".item img:first-child").eq(0).width();
var cases = $(".Solve")
//轮播图主程序
function selectPic(num) {
	$(".page li").eq(num).addClass("active").siblings().removeClass("active");
	$("#lunBo").animate({
		left: -num * imgWidth,
	}, 800, function() {
		//检查是否到最后一张
		if (index == cases.length - 1) {
			index %= 2;
			$(".item").css("left", "0px");
			$(".page li").eq(0).addClass("active").siblings().removeClass("active");
		}
	})
}

function autoGo(bol) {
	//自动行走
	if (bol) {
		timer = setInterval(go, 3000);
	}
}
autoGo(flag);

function go() {
	//计时器的函数
	index++;
	selectPic(index);
}


function loadList() {
	var url = "http://10.0.5.212/PHP/project/wang_wen_jun/wqlist.php";
	$.ajax({
			url: url,
			type: "get",
			success: function(res) {
				var obj = JSON.parse(res);
				var html = "";
				var html1 = "";
				obj.data.forEach(userinfo => {
					html +=`你好,母婴之家用户,<span>${userinfo.username}</span>`
					html1 += `
						<li><a href="javascript:;">手机版</a></li>
						<li><a href="javascript:;">我要开店</a></li>
						<li><a href="register.html">你好,${userinfo.username}</a></li>
						<li><a href="javascript:;">商务合作</a></li>
						<li><a href="javascript:;">我的订单</a></li>
					`
				})
			    $(".name_p").html(html);
				$(".ul_nav").html(html1);
			},
	})
}
loadList();


	